import React, { Component } from 'react';
import { Modal } from 'antd';
import BaseForm from '../BaseForm/index.jsx';

class FormModal extends Component {

  handleOk = () => {
    const { modalProps={} } = this.props;
    const { onOk } = modalProps;
    const submitObjValue = this.BaseForm.handleSubmit();
    onOk && onOk(submitObjValue);
  }

  render() {
    const { modalProps={}, formProps={} } = this.props;

    return (
      <Modal {...modalProps} onOk={this.handleOk}>
        <BaseForm {...formProps} columns={formProps.columns || 1}  wrappedComponentRef={inst => this.BaseForm = inst}></BaseForm>
      </Modal>
    );
  }
}

export default FormModal;